<!--添加管理员-->
<div class="dialog_content">
	<form id="info_form" name="info_form" action="{:U('Admin/add')}" method="post">
	<table width="100%" class="table_form">
		<tr> 
	      <th width="80">{:L('admin_username')} :</th>
	      <td><input type="text" name="username" id="J_username" class="input-text"></td>
	    </tr>
        <tr>
            <th width="80">所属角色 :</th>
            <td>
                <select name="role_id" id="role">
					<option value="0">请选择</option>
                    <volist name="role" id="vo">
                        <option value="{$vo.id}" level="{$vo.level_area}">{$vo.title}</option>
                    </volist>
                </select>
            </td>
        </tr>
	    <tr> 
	      <th>{:L('password')} :</th>
	      <td><input type="password" name="password" id="J_password" class="input-text"></td>
	    </tr>
	    <tr>
	      <th>{:L('cofirmpwd')} :</th>
	      <td><input type="password" name="repassword" id="J_repassword" class="input-text"></td>
	    </tr>
		<tr>
			<th>管辖区域 :</th>
			<td>
				<select name="scope" id="scope">
						<option value="0">请选择</option>
				</select>
			</td>
		</tr>
	    <tr>
	    	<th>{:L('admin_email')} :</th>
	    	<td><input type="text" name="email" class="input-text" size="30"></td>
	    </tr>

	</table>
	</form>
</div>
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	
	$("#J_username").formValidator({ onshow:lang.please_input+lang.admin_username, onfocus:lang.please_input+lang.admin_username}).inputValidator({ min:1, onerror:lang.please_input+lang.admin_username}).ajaxValidator({type:"get", url:"", data:"m=Admin&c=admin&a=ajax_check_name", datatype:"html", async:'false', success:function(data){ if(data == "1"){return true;}else{return false;}}, onerror:lang.admin_name_exists, onwait:lang.connecting_please_wait});
	$("#J_password").formValidator({ onshow:lang.please_input+lang.password, onfocus:lang.password+lang.between_6_to_20}).inputValidator({ min:6, max:20, onerror:lang.password+lang.between_6_to_20});
	$("#J_repassword").formValidator({ onshow:lang.cofirmpwd, onfocus:lang.cofirmpwd}).compareValidator({desid:"J_password",operateor:"=",onerror:lang.passwords_not_match});

	$('#info_form').ajaxForm({success:complate,dataType:'json'});
    function complate(result){
        if(result.status == 1){
            $.dialog.get(result.dialog).close();
            $.pinphp.tip({content:result.msg});
            window.location.reload();
        } else {
            $.pinphp.tip({content:result.msg, icon:'alert'});
        }
    }
    $('#role').change(function (){
		var attr = $(this).find ("option:selected").attr ("level");
		if (attr == 0){
			var url = "{:U('division/ajax_get_group')}";
			var data = {};
		} else if (attr == 1){
			var url = "{:U('shop/ajax_get_shop')}";
			var data = {};
		} else{
			var url = "{:U('AreaCate/ajax_get_area')}";
			var data = {attr:attr};
		}
		$.get (url, data, function (data){
				if (typeof(data)!="undefined"){
					var html = '';

					$.each(data, function(p1, p2){
						html += '<option value="'+p2.id+'">'+p2.title+'</option>';
					});
					$('#scope option[value="0"]').nextAll().remove();
					$('#scope').append(html);
				}

		},'json')
	})
});
</script>